package com.hs.service.impl;

import com.hs.entity.Classes;
import com.hs.entity.Ctc;
import com.hs.mapper.ClassesMapper;
import com.hs.mapper.CtcMapper;
import com.hs.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ClassServiceImpl implements ClassService {

    @Autowired
    private CtcMapper ctcMapper;

    @Autowired
    private ClassesMapper classesMapper;

    @Override
    public List<Classes> queryAllClass() {
        return classesMapper.queryAllClass();
    }

    @Override
    public Integer addClass(Classes classes) {
        return classesMapper.addClass(classes);
    }

    @Override
    public int multiindert(List<String> cids, List<String> types, List<String> tids, int weekid, int claid) {
        List<Ctc> ctcList=new ArrayList<Ctc>();
        for(int i=0;i<tids.size();i++){
            if(!tids.get(i).equals("0") && !cids.get(i).equals("0")){
                Ctc ctc=new Ctc();
                ctc.setClaid(claid);
                ctc.setType(types.get(i));
                ctc.setCouid(Integer.parseInt(cids.get(i)));
                ctc.setTid(Integer.parseInt(tids.get(i)));
                ctc.setTimeid(i+1);
                ctc.setWeekid(weekid);
                ctcList.add(ctc);
            }
        }
        int row=ctcMapper.multiinsert(ctcList);
        return row;
    }


}
